package com.micro.core.configuration;

import org.springframework.boot.autoconfigure.AutoConfigureAfter;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import tk.mybatis.spring.mapper.MapperScannerConfigurer;

/**
 * @Classname MybatisMapperScannerConfiguration
 * @Description 配置mapper自动扫描
 * @Author 汽车下的路灯
 * @Date 2019-11-28 下午 4:57
 * @Version 1.0.0
 */
@Configuration
@AutoConfigureAfter({MybatisConfiguration.class})
public class MybatisMapperScannerConfiguration {

    /** mapper接口的 包路径 */
    private static final String MAPPER_PATH = "com.micro.modual.mapper";

    @Bean
    public MapperScannerConfigurer mapperScannerConfigurer(){
        MapperScannerConfigurer mapperScannerConfigurer = new MapperScannerConfigurer();
        mapperScannerConfigurer.setSqlSessionFactoryBeanName(MybatisConfiguration.SQL_SESSION_FACTORY);
        mapperScannerConfigurer.setBasePackage(MAPPER_PATH);
        return mapperScannerConfigurer;
    }

}
